function coloring() {
    let r = Math.floor(Math.random() * 255)
    let g = Math.floor(Math.random() * 255)
    let b = Math.floor(Math.random() * 255)
    document.body.style.background = `rgb(${r},${g},${b})`;

}

function throttle(func, delay) {
    let timer;
    return function () {
        let context = this;
        let args = arguments;
        if (timer) return;

        timer = setTimeout(function () {
            func.apply(context, args);
            timer = null;
        }, delay)
    }
}

window.addEventListener('resize', throttle(coloring, 2000));